#include "cabina.h"
#include <iostream>

Cabina::Cabina(Hombro* hombro){
	anguloGiro = 0;
	this->hombro = hombro;
	inicializar();
}

void Cabina::ejecucion() const{
	glPushMatrix();		
		//Plataforma
		glPushMatrix();
			glScalef(2,1.2,0.1);
			glutSolidCube(1);
		glPopMatrix();
		//Parte trasera	
		glPushMatrix();
			glTranslatef(-0.8,0,0.1);
			glScalef(0.2,1,0.2);		
			glutSolidCube(1);
		glPopMatrix();
		//Cabina
		glPushMatrix();
			glTranslatef(0.3,-0.25,0.4);		
			glScalef(1.2,0.6,0.7);
			glutSolidCube(1);
			//Ventana de la cabina
			glPushMatrix();
				glColor3f(0,0,0);			
				glTranslatef(0.25,0,0.15);			
				glScalef(0.6,1.1,0.5);
				glutSolidCube(1);
				glColor3ub(255,198,0);
			glPopMatrix();
		glPopMatrix();

}

void Cabina::dibujar() const{
	glRotatef(this->anguloGiro,0,0,1);
	glColor3ub(255,198,0);
	DisplayList::dibujar();
	//Base del brazo
	glPushMatrix();
		glTranslatef(0.5,0.4,0.15);
		glScalef(0.2,0.2,0.2);
		glutSolidCube(1);
		hombro->dibujar();
	glPopMatrix();
	glPopMatrix();
	//ejecucion();
}
	
void Cabina::giroDerecha(float angulo){
	this->anguloGiro += angulo;
	if(anguloGiro>=360) anguloGiro= 0 + angulo;
}

void Cabina::giroIzquierda(float angulo){
	this->anguloGiro-= angulo;
	if(anguloGiro<0) anguloGiro = 359 - angulo;
}
